package com.hemerasolutions.v2trainer.model.base;

import java.util.ArrayList;
import java.util.List;

import com.hemerasolutions.v2trainer.model.interfaces.BaseMultimediaModelInterface;
import com.hemerasolutions.v2trainer.model.multimedia.Photo;
import com.hemerasolutions.v2trainer.model.multimedia.Video;

public class BaseMultimediaModel extends BaseModel implements BaseMultimediaModelInterface  {

	private static final long serialVersionUID = 1L;

	private List<Video> videos;
	
	private List<Photo> photos;
	
	
	public BaseMultimediaModel(){
		super();
		this.photos = new ArrayList<Photo>();
		this.videos = new ArrayList<Video>();
	}
	

	@Override
	public Video getPrincipalVideo() {
		Video video = null;
		if(this.videos != null && !this.videos.isEmpty()){
			video = this.videos.get(0);
			for(Video videoAux:this.videos){
				if(videoAux.isPrincipal()){
					video = videoAux ;
				}
			}
		}
		return video;
	}

	@Override
	public void setPrincipalVideo(Video video) {
		for(Video aux:this.videos){
			if(aux.equals(video)){
				aux.setPrincipal(true);
			}else{
				aux.setPrincipal(false);
			}
		}
	}


	@Override
	public Photo getPrincipalPhoto() {
		Photo photo = null;
		if(this.photos != null && !this.photos.isEmpty()){
			photo = this.photos.get(0);
			for(Photo photoAux:this.photos){
				if(photoAux.isPrincipal()){
					photo = photoAux;
					break;
				}
			}
		}
		return photo;
	}

	@Override
	public void setPrincipalPhoto(Photo photo) {
		for(Photo aux:this.photos){
			if(aux.equals(photo)){
				aux.setPrincipal(true);
			}else{
				aux.setPrincipal(false);
			}
		}		
	}


	@Override
	public List<Video> getVideos() {
		return videos;
	}


	@Override
	public void setVideos(List<Video> videos) {
		this.videos = videos;
	}


	@Override
	public List<Photo> getPhotos() {
		return photos;
	}


	@Override
	public void setPhotos(List<Photo> photos) {
		this.photos = photos;
	}
	



}
